1 Setup

library("tidyverse")
library("here")
library("assertthat")
library("VIM")
library("janitor")
library("ggstatsplot")
library("glue")
library("gt")
library("rstatix")
library("broom")
library("futile.logger")
library("gt")
library("infer")

conflicted::conflict_prefer("discard", "purrr")
conflicted::conflict_prefer("filter", "dplyr")
flog.appender(appender.file("covid-icu.log"))
flog.threshold(INFO)
flog.info("STARTING script 02")
flog.info("Logger inited")
source(here("src", "01-constants.R"))
source(here("src", "funs", "prepare-data.R"))
source(here("src", "funs", "helper-funs.R"))
source(here("src", "funs", "prop_NA.R"))
source(here("src", "funs", "compare_progression.R"))
source(here("src", "funs", "is_binary.R"))

2 Import data

if (params$dataset == "small") {
  d <- read_csv(here("data", "processed", "data-small-prepared.csv"))
} else {
  d <- read_csv(here("data", "processed", "data-prepared.csv"))
}

3 Compare progression for metric variables

names_binary_vars <- 
d %>% 
  keep(is_binary, na.rm = TRUE) %>% 
  names()

names_binary_vars
##  [1] "verlauf"                                            
##  [2] "geschlecht"                                         
##  [3] "supportive_o2"                                      
##  [4] "fieber"                                             
##  [5] "husten"                                             
##  [6] "dyspnoe"                                            
##  [7] "geruchs_geschmacksverlust"                          
##  [8] "kopfschm"                                           
##  [9] "gliederschm"                                        
## [10] "abgeschlagenheit"                                   
## [11] "schuttelfrost"                                      
## [12] "halsschmerzen"                                      
## [13] "diarrho_emesis"                                     
## [14] "mutation"                                           
## [15] "dm"                                                 
## [16] "adipositas"                                         
## [17] "art_hypert"                                         
## [18] "chron_herzerkr"                                     
## [19] "asthma_bronchiale"                                  
## [20] "nicht_asthmat_lungenerkr"                           
## [21] "chron_nierenerkrankung"                             
## [22] "nikotinabusus"                                      
## [23] "maligne_vorerkrankung"                              
## [24] "ns_hf"                                              
## [25] "niv"                                                
## [26] "beatmung_imv"                                       
## [27] "ecmo"                                               
## [28] "dialyse"                                            
## [29] "tod"                                                
## [30] "sepsis"                                             
## [31] "blutungen"                                          
## [32] "resp_insuff"                                        
## [33] "pneumonie_bakterielle_virale_fungale_superinfektion"
## [34] "kardiale_beteiligung_tara_vhf_mi"                   
## [35] "akutes_nierenversagen"
names_metric_vars <-
  d %>% 
  keep(negate(~ is_binary(., na.rm = TRUE))) %>% 
  names()

names_metric_vars
##  [1] "id"                        "alter"                    
##  [3] "af"                        "sat_percent"              
##  [5] "hf"                        "bp_sys"                   
##  [7] "bp_dia"                    "gcs"                      
##  [9] "temp"                      "esi"                      
## [11] "q_sofa"                    "ven_bga_p_co2_mm_hg"      
## [13] "vbga_p_o2_mm_hg"           "ven_laktat_mmol_l"        
## [15] "fi_o2_umgerechnet_percent" "leukos_nl"                
## [17] "thrombos_nl"               "neutros_nl"               
## [19] "lymphos_nl"                "nlr"                      
## [21] "quick_percent"             "harnstoff_mg_dl"          
## [23] "crea_mg_dl"                "e_gfr_ml_min"             
## [25] "bilirubin_ges_mg_d_l"      "ast_u_l"                  
## [27] "alt_u_l"                   "ldh_u_l"                  
## [29] "crp_mg_d_l"                "procalcitonin_ng_m_l"     
## [31] "ro"                        "bg"

3.1 Comparing metric variables with regard to progress (bad/good)

List of metric variables to be compared with regard to progress (bad/good):

cols_to_be_compared_metric <-
  names_metric_vars %>% 
  discard(~ .x %in% c("fallnummer", "verlauf", "id"))

cols_to_be_compared_metric
##  [1] "alter"                     "af"                       
##  [3] "sat_percent"               "hf"                       
##  [5] "bp_sys"                    "bp_dia"                   
##  [7] "gcs"                       "temp"                     
##  [9] "esi"                       "q_sofa"                   
## [11] "ven_bga_p_co2_mm_hg"       "vbga_p_o2_mm_hg"          
## [13] "ven_laktat_mmol_l"         "fi_o2_umgerechnet_percent"
## [15] "leukos_nl"                 "thrombos_nl"              
## [17] "neutros_nl"                "lymphos_nl"               
## [19] "nlr"                       "quick_percent"            
## [21] "harnstoff_mg_dl"           "crea_mg_dl"               
## [23] "e_gfr_ml_min"              "bilirubin_ges_mg_d_l"     
## [25] "ast_u_l"                   "alt_u_l"                  
## [27] "ldh_u_l"                   "crp_mg_d_l"               
## [29] "procalcitonin_ng_m_l"      "ro"                       
## [31] "bg"
cols_to_be_compared_metric %>% 
  map(~ compare_progression_metric(d, 
                                   group = verlauf, 
                                   var = .))

3.2 alter

Starting analysis for variable: alter

Grouping variable: verlauf


3.2.1 Violin plot

3.2.2 Histogram

3.2.3 Table

3.2.4 Inference: t-Test between the two groups:

3.2.5 Visualizing differences between the two groups:


End of analysis for variable: alter

3.3 af

Starting analysis for variable: af

Grouping variable: verlauf


3.3.1 Violin plot

3.3.2 Histogram

3.3.3 Table

3.3.4 Inference: t-Test between the two groups:

3.3.5 Visualizing differences between the two groups:


End of analysis for variable: af

3.4 sat_percent

Starting analysis for variable: sat_percent

Grouping variable: verlauf


3.4.1 Violin plot

3.4.2 Histogram

3.4.3 Table

3.4.4 Inference: t-Test between the two groups:

3.4.5 Visualizing differences between the two groups:


End of analysis for variable: sat_percent

3.5 hf

Starting analysis for variable: hf

Grouping variable: verlauf


3.5.1 Violin plot

3.5.2 Histogram

3.5.3 Table

3.5.4 Inference: t-Test between the two groups:

3.5.5 Visualizing differences between the two groups:


End of analysis for variable: hf

3.6 bp_sys

Starting analysis for variable: bp_sys

Grouping variable: verlauf


3.6.1 Violin plot

3.6.2 Histogram

3.6.3 Table

3.6.4 Inference: t-Test between the two groups:

3.6.5 Visualizing differences between the two groups:


End of analysis for variable: bp_sys

3.7 bp_dia

Starting analysis for variable: bp_dia

Grouping variable: verlauf


3.7.1 Violin plot

3.7.2 Histogram

3.7.3 Table

3.7.4 Inference: t-Test between the two groups:

3.7.5 Visualizing differences between the two groups:


End of analysis for variable: bp_dia

3.8 gcs

Starting analysis for variable: gcs

Grouping variable: verlauf


3.8.1 Violin plot

3.8.2 Histogram

3.8.3 Table

3.8.4 Inference: t-Test between the two groups:

3.8.5 Visualizing differences between the two groups:


End of analysis for variable: gcs

3.9 temp

Starting analysis for variable: temp

Grouping variable: verlauf


3.9.1 Violin plot

3.9.2 Histogram

3.9.3 Table

3.9.4 Inference: t-Test between the two groups:

3.9.5 Visualizing differences between the two groups:


End of analysis for variable: temp

3.10 esi

Starting analysis for variable: esi

Grouping variable: verlauf


3.10.1 Violin plot

3.10.2 Histogram

3.10.3 Table

3.10.4 Inference: t-Test between the two groups:

3.10.5 Visualizing differences between the two groups:


End of analysis for variable: esi

3.11 q_sofa

Starting analysis for variable: q_sofa

Grouping variable: verlauf


3.11.1 Violin plot

3.11.2 Histogram

3.11.3 Table

3.11.4 Inference: t-Test between the two groups:

3.11.5 Visualizing differences between the two groups:


End of analysis for variable: q_sofa

3.12 ven_bga_p_co2_mm_hg

Starting analysis for variable: ven_bga_p_co2_mm_hg

Grouping variable: verlauf


3.12.1 Violin plot

3.12.2 Histogram

3.12.3 Table

3.12.4 Inference: t-Test between the two groups:

3.12.5 Visualizing differences between the two groups:


End of analysis for variable: ven_bga_p_co2_mm_hg

3.13 vbga_p_o2_mm_hg

Starting analysis for variable: vbga_p_o2_mm_hg

Grouping variable: verlauf


3.13.1 Violin plot

3.13.2 Histogram

3.13.3 Table

3.13.4 Inference: t-Test between the two groups:

3.13.5 Visualizing differences between the two groups:


End of analysis for variable: vbga_p_o2_mm_hg

3.14 ven_laktat_mmol_l

Starting analysis for variable: ven_laktat_mmol_l

Grouping variable: verlauf


3.14.1 Violin plot

3.14.2 Histogram

3.14.3 Table

3.14.4 Inference: t-Test between the two groups:

3.14.5 Visualizing differences between the two groups:


End of analysis for variable: ven_laktat_mmol_l

3.15 fi_o2_umgerechnet_percent

Starting analysis for variable: fi_o2_umgerechnet_percent

Grouping variable: verlauf


3.15.1 Violin plot

3.15.2 Histogram

3.15.3 Table

3.15.4 Inference: t-Test between the two groups:

3.15.5 Visualizing differences between the two groups:


End of analysis for variable: fi_o2_umgerechnet_percent

3.16 leukos_nl

Starting analysis for variable: leukos_nl

Grouping variable: verlauf


3.16.1 Violin plot

3.16.2 Histogram

3.16.3 Table

3.16.4 Inference: t-Test between the two groups:

3.16.5 Visualizing differences between the two groups:


End of analysis for variable: leukos_nl

3.17 thrombos_nl

Starting analysis for variable: thrombos_nl

Grouping variable: verlauf


3.17.1 Violin plot

3.17.2 Histogram

3.17.3 Table

3.17.4 Inference: t-Test between the two groups:

3.17.5 Visualizing differences between the two groups:


End of analysis for variable: thrombos_nl

3.18 neutros_nl

Starting analysis for variable: neutros_nl

Grouping variable: verlauf


3.18.1 Violin plot

3.18.2 Histogram

3.18.3 Table

3.18.4 Inference: t-Test between the two groups:

3.18.5 Visualizing differences between the two groups:


End of analysis for variable: neutros_nl

3.19 lymphos_nl

Starting analysis for variable: lymphos_nl

Grouping variable: verlauf


3.19.1 Violin plot

3.19.2 Histogram

3.19.3 Table

3.19.4 Inference: t-Test between the two groups:

3.19.5 Visualizing differences between the two groups:


End of analysis for variable: lymphos_nl

3.20 nlr

Starting analysis for variable: nlr

Grouping variable: verlauf


3.20.1 Violin plot

3.20.2 Histogram

3.20.3 Table

3.20.4 Inference: t-Test between the two groups:

3.20.5 Visualizing differences between the two groups:


End of analysis for variable: nlr

3.21 quick_percent

Starting analysis for variable: quick_percent

Grouping variable: verlauf


3.21.1 Violin plot

3.21.2 Histogram

3.21.3 Table

3.21.4 Inference: t-Test between the two groups:

3.21.5 Visualizing differences between the two groups:


End of analysis for variable: quick_percent

3.22 harnstoff_mg_dl

Starting analysis for variable: harnstoff_mg_dl

Grouping variable: verlauf


3.22.1 Violin plot

3.22.2 Histogram

3.22.3 Table

3.22.4 Inference: t-Test between the two groups:

3.22.5 Visualizing differences between the two groups:


End of analysis for variable: harnstoff_mg_dl

3.23 crea_mg_dl

Starting analysis for variable: crea_mg_dl

Grouping variable: verlauf


3.23.1 Violin plot

3.23.2 Histogram

3.23.3 Table

3.23.4 Inference: t-Test between the two groups:

3.23.5 Visualizing differences between the two groups:


End of analysis for variable: crea_mg_dl

3.24 e_gfr_ml_min

Starting analysis for variable: e_gfr_ml_min

Grouping variable: verlauf


3.24.1 Violin plot

3.24.2 Histogram

3.24.3 Table

3.24.4 Inference: t-Test between the two groups:

3.24.5 Visualizing differences between the two groups:


End of analysis for variable: e_gfr_ml_min

3.25 bilirubin_ges_mg_d_l

Starting analysis for variable: bilirubin_ges_mg_d_l

Grouping variable: verlauf


3.25.1 Violin plot

3.25.2 Histogram

3.25.3 Table

3.25.4 Inference: t-Test between the two groups:

3.25.5 Visualizing differences between the two groups:


End of analysis for variable: bilirubin_ges_mg_d_l

3.26 ast_u_l

Starting analysis for variable: ast_u_l

Grouping variable: verlauf


3.26.1 Violin plot

3.26.2 Histogram

3.26.3 Table

3.26.4 Inference: t-Test between the two groups:

3.26.5 Visualizing differences between the two groups:


End of analysis for variable: ast_u_l

3.27 alt_u_l

Starting analysis for variable: alt_u_l

Grouping variable: verlauf


3.27.1 Violin plot

3.27.2 Histogram

3.27.3 Table

3.27.4 Inference: t-Test between the two groups:

3.27.5 Visualizing differences between the two groups:


End of analysis for variable: alt_u_l

3.28 ldh_u_l

Starting analysis for variable: ldh_u_l

Grouping variable: verlauf


3.28.1 Violin plot

3.28.2 Histogram

3.28.3 Table

3.28.4 Inference: t-Test between the two groups:

3.28.5 Visualizing differences between the two groups:


End of analysis for variable: ldh_u_l

3.29 crp_mg_d_l

Starting analysis for variable: crp_mg_d_l

Grouping variable: verlauf


3.29.1 Violin plot

3.29.2 Histogram

3.29.3 Table

3.29.4 Inference: t-Test between the two groups:

3.29.5 Visualizing differences between the two groups:


End of analysis for variable: crp_mg_d_l

3.30 procalcitonin_ng_m_l

Starting analysis for variable: procalcitonin_ng_m_l

Grouping variable: verlauf


3.30.1 Violin plot

3.30.2 Histogram

3.30.3 Table

3.30.4 Inference: t-Test between the two groups:

3.30.5 Visualizing differences between the two groups:


End of analysis for variable: procalcitonin_ng_m_l

3.31 ro

Starting analysis for variable: ro

Grouping variable: verlauf


3.31.1 Violin plot

3.31.2 Histogram

3.31.3 Table

3.31.4 Inference: t-Test between the two groups:

3.31.5 Visualizing differences between the two groups:


End of analysis for variable: ro

3.32 bg

Starting analysis for variable: bg

Grouping variable: verlauf


3.32.1 Violin plot

3.32.2 Histogram

3.32.3 Table

3.32.4 Inference: t-Test between the two groups:

3.32.5 Visualizing differences between the two groups:


End of analysis for variable: bg

[[1]] NULL

[[2]] NULL

[[3]] NULL

[[4]] NULL

[[5]] NULL

[[6]] NULL

[[7]] NULL

[[8]] NULL

[[9]] NULL

[[10]] NULL

[[11]] NULL

[[12]] NULL

[[13]] NULL

[[14]] NULL

[[15]] NULL

[[16]] NULL

[[17]] NULL

[[18]] NULL

[[19]] NULL

[[20]] NULL

[[21]] NULL

[[22]] NULL

[[23]] NULL

[[24]] NULL

[[25]] NULL

[[26]] NULL

[[27]] NULL

[[28]] NULL

[[29]] NULL

[[30]] NULL

[[31]] NULL

4 Comparing nominal variables with regard to p rogress (bad/good)

cols_to_be_compared_binary <-
  names_binary_vars %>% 
  discard(~ .x %in% c("fallnr", "verlauf"))
d_factor <-
  d %>%
  select(verlauf, all_of(cols_to_be_compared_binary)) %>%
  mutate(across(everything(),
                factor))

4.1 Vis (pie charts)

ggpiestats(data = d, x = verlauf, y = ns_hf, bf.message = FALSE, title = "ns_hf")

ggpiestats(data = d, x = verlauf, y = niv, bf.message = FALSE, title = "niv")

ggpiestats(data = d, x = verlauf, y = resp_insuff, bf.message = FALSE, title = "resp_insuff")

ggpiestats(data = d, x = verlauf, y = beatmung_imv, bf.message = FALSE, title = "beatmung_imv")

ggpiestats(data = d, x = verlauf, y = pneumonie_bakterielle_virale_fungale_superinfektion, bf.message = FALSE, title = "pneumonie_bakterielle_virale_fungale_superinfektion")

ggpiestats(data = d, x = verlauf, y = sepsis, bf.message = FALSE, title = "sepsis")

ggpiestats(data = d, x = verlauf, y = kardiale_beteiligung_tara_vhf_mi, bf.message = FALSE, title = "kardiale_beteiligung_tara_vhf_mi")

ggpiestats(data = d, x = verlauf, y = tod, bf.message = FALSE, title = "tod")

ggpiestats(data = d, x = verlauf, y = dyspnoe, bf.message = FALSE, title = "dyspnoe")

ggpiestats(data = d, x = verlauf, y = nikotinabusus, bf.message = FALSE, title = "nikotinabusus")

ggpiestats(data = d, x = verlauf, y = art_hypert, bf.message = FALSE, title = "art_hypert")

ggpiestats(data = d, x = verlauf, y = dm, bf.message = FALSE, title = "dm")

ggpiestats(data = d, x = verlauf, y = geschlecht, bf.message = FALSE, title = "geschlecht")

ggpiestats(data = d, x = verlauf, y = kopfschm, bf.message = FALSE, title = "kopfschm")

ggpiestats(data = d, x = verlauf, y = adipositas, bf.message = FALSE, title = "adipositas")